<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .da {
            margin: 100px auto;
            height: 622px;
            width: 1070px;
            box-shadow: 0 0 5px;
            border: 1px solid black;
            overflow: hidden;
        }

        .zuo {
            width: 853px;
            height: 622px;
            float: left;
        }

        .zuo ul {

            position: relative;
            top: 0;
            transition: 0.2s linear;
            /* 匀速转换时间 */

        }

        .zuo ul li {

            width: 853px;
            height: 622px;
        }

        .zuo ul li img {
            width: 853px;
            height: 622px;
            box-sizing: border-box;
            /* 盒模型 */
            padding: 15px;
            border-radius: 20px;
            object-fit: cover;

        }

        .you {
            width: 1px;
            height: 100%;
            float: right;
            position: relative;
        }

        .you:hover {
            cursor: pointer;
        }

        .you ol li {
            height: 125px;
            width: 193px;
            text-align: center;
            position: relative;
            float: right;

        }

        .you ol li img {
            width: 193px;
            height: 119px;
            border-radius: 6px;
            opacity: 0.5;
            vertical-align: top;
            box-sizing: border-box;
            padding: 15px;
            object-fit: cover;
        }

        .you span {
            position: absolute;
            right: 70px;
            padding: 10px;
            font-size: 12px;

            color: #fff;
            background-color: rgba(0, 0, 0, 0.361);
            border-radius: 20px;
            z-index: 10;
        }

        .prev {
            top: 0px;
        }

        .next {
            bottom: 0px;
        }

        span {
            position: absolute;
            right: 40%;
            padding: 10px;
            font-size: 12px;
            color: #fff;
            background-color: rgba(0, 0, 0, 0.361);
            border-radius: 20px;
            z-index: 10;
        }

        .kuang {
            height: 86px;
            width: 160px;
            border: 5px solid red;
            transform: translate(0px, 0px);
            transition: 0.2s linear;
            position: absolute;
            top: 10px;
            left: 11px;
            border-radius: 5px;
        }

        p {
            position: absolute;
            top: 54px;
            left: 1px;
            transform: translate(0px, 0px);
            transition: 0.2s linear;
            width: 0;
            height: 0;
            border-right: 10px solid rgb(255, 0, 0);
            border-top: 5px solid transparent;
            border-bottom: 5px solid transparent;
        }
    </style>
</head>

<body>
    <div class="da">
        <div class="zuo">
            <ul>
                <ul>
                    <li><img src="./img/小姐姐1.jpeg" alt=""></li>
                    <li><img src="./img/小姐姐2.jpeg" alt=""></li>
                    <li><img src="./img/小姐姐3.jpeg" alt=""></li>
                    <li><img src="./img/小姐姐4.jpeg" alt=""></li>
                    <li><img src="./img/小姐姐5.jpeg" alt=""></li>
                    <li><img src="./img/小姐姐6.jpeg" alt=""></li>
                    <li><img src="./img/小姐姐7.jpeg" alt=""></li>
                </ul>
        </div>
        <div class="you">
            <span class="prev">上</span>
            <ol>
                <li>
                    <p></p>
                    <div class="kuang"></div>
                    <img src="./img/小姐姐1.jpeg" alt="">
                </li>
                <li><img src="./img/小姐姐2.jpeg" alt=""></li>
                <li><img src="./img/小姐姐3.jpeg" alt=""></li>
                <li><img src="./img/小姐姐4.jpeg" alt=""></li>
                <li><img src="./img/小姐姐5.jpeg" alt=""></li>
                <li><img src="./img/小姐姐6.jpeg" alt=""></li>
                <li><img src="./img/小姐姐7.jpeg" alt=""></li>
            </ol>
            <span class="next">下</span>
        </div>
    </div>
    <script>
        var lis = document.querySelector('ul').querySelectorAll('li');
        var ul = document.querySelector('ul');
        var ollis = document.querySelector('ol').querySelectorAll('li');
        var ol = document.querySelector('ol');
        var lish = document.querySelector('ul').querySelector('li').offsetHeight;
        var ollish = document.querySelector('ol').querySelector('li').offsetHeight;

        // 1.点击右边的ol的li,设置.border移动到点击这个li上; 再设置左边ul的相对应的li显示
        // 2.点击上下按钮,设置右边ol里li显示下一个

        // 1. 
        var prev = document.querySelector(".prev");
        var next = document.querySelector(".next");
        var p = document.querySelector('p');
        console.log(lis);
        for (let i = 0; i < ollis.length; i++) {
            ollis[i].onmouseenter = function () {
                var z = i * -lish;
                var y = i * ollish;
                console.log(z);
                ul.style.top = z + "px";
                ol.querySelector('.kuang').style.transform = `translate(0px, ${y}px)`;
                p.style.transform = `translate(0px, ${y}px)`;
                for (let i = 0; i < ollis.length; i++) {
                    ollis[i].querySelector('img').style.opacity = 0.5;

                }
                ollis[i].querySelector('img').style.opacity = 1;
            }

        }



        var index = 0;
        next.onclick = function () {
            index++;
            if (index > 2) index = 2;
            ol.style.transform = `translate(0px, ${-ollish * index}px)`;

        }

        prev.onclick = function () {
            index--;
            if (index < 0) index = 0; //最小值为0
            ol.style.transform = `translate(0px, ${-ollish * index}px)`;

        }

    </script>
</body>

</html>